<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>structs.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">structs.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    <span class='nodesc'>No description.</span>
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_structs_structs.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/structs/structs.js">Git</a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">/goog/structs/structs.js</div>
    </div>
  </div>
<hr/>


   
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.clear"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">clear<span class="args">(<span class="arg">col</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Removes all the elements from the collection.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line148">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.contains"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">contains<span class="args">(<span class="arg">col</span>,&nbsp;<span class="arg">val</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Whether the collection contains the given value. This is O(n) and uses
equals (==) to test the existence.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">val</span>
        : <span class="type">*</span>
        <div class="entryOverview">The value to check for.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            True if the map contains the value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line110">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.every"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">every<span class="args">(<span class="arg">col</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Calls f for each value in a collection. If all calls return true this return
true this returns true. If any returns false this returns false at this point
 and does not continue to check the remaining values.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type">S</span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <span class="type">function(this:T,?,?,S):boolean</span>
        <div class="entryOverview">The function to call for every
    value. This function takes 3 arguments (the value, the key or
    undefined if the collection has no notion of keys, and the collection)
    and should return a boolean.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <span class="type">T=</span>
        <div class="entryOverview">The object to be used as the value of 'this'
    within <code> f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            True if all key-value pairs pass the test.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line338">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.filter"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">filter<span class="args">(<span class="arg">col</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>
      </div>


     <div class="entryOverview">
       Calls a function for every value in the collection. When a call returns true,
adds the value to a new collection (Array is returned by default).


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type">S</span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <span class="type">function(this:T,?,?,S):boolean</span>
        <div class="entryOverview">The function to call for every
    value. This function takes
    3 arguments (the value, the key or undefined if the collection has no
    notion of keys, and the collection) and should return a Boolean. If the
    return value is true the value is added to the result collection. If it
    is false the value is not included.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <span class="type">T=</span>
        <div class="entryOverview">The object to be used as the value of 'this'
    within <code> f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span><span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>&nbsp;
            A new collection where the passed values are
    present. If col is a key-less collection an array is returned.  If col
    has keys and values a plain old JS object is returned.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line210">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.forEach"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">forEach<span class="args">(<span class="arg">col</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Calls a function for each value in a collection. The function takes
three arguments; the value, the key and the collection.

NOTE: This will be deprecated soon! Please use a more specific method if
possible, e.g. goog.array.forEach, goog.object.forEach, etc.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type">S</span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <span class="type">function(this:T,?,?,S</span>)<span>:?</span>
        <div class="entryOverview">The function to call for every value.
    This function takes
    3 arguments (the value, the key or undefined if the collection has no
    notion of keys, and the collection) and the return value is irrelevant.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <span class="type">T=</span>
        <div class="entryOverview">The object to be used as the value of 'this'
    within <code> f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line176">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.getCount"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">getCount<span class="args">(<span class="arg">col</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Returns the number of values in the collection-like object.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The number of values in the collection-like object.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line41">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.getKeys"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">getKeys<span class="args">(<span class="arg">col</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>
      </div>


     <div class="entryOverview">
       Returns the keys of the collection. Some collections have no notion of
keys/indexes and this function will return undefined in those cases.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>&nbsp;
            The keys in the collection.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line82">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.getValues"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">getValues<span class="args">(<span class="arg">col</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>
      </div>


     <div class="entryOverview">
       Returns the values of the collection-like object.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>&nbsp;
            The values in the collection-like object.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line57">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.isEmpty"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">isEmpty<span class="args">(<span class="arg">col</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Whether the collection is empty.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            True if empty.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line129">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.map"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">map<span class="args">(<span class="arg">col</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>.&lt;<span class="type">V</span>&gt;<span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type">V</span>&gt;
      </div>


     <div class="entryOverview">
       Calls a function for every value in the collection and adds the result into a
new collection (defaults to creating a new Array).


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type">S</span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <span class="type">function(this:T,?,?,S):V</span>
        <div class="entryOverview">The function to call for every value.
    This function takes 3 arguments (the value, the key or undefined if the
    collection has no notion of keys, and the collection) and should return
    something. The result will be used as the value in the new collection.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <span class="type">T=</span>
        <div class="entryOverview">The object to be used as the value of 'this'
    within <code> f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>.&lt;<span class="type">V</span>&gt;<span>&nbsp;|&nbsp;</span><span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type">V</span>&gt;&nbsp;
            A new collection with the new values.  If
    col is a key-less collection an array is returned.  If col has keys and
    values a plain old JS object is returned.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line260">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.structs.some"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.structs.</span><span class="entryName">some<span class="args">(<span class="arg">col</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Calls f for each value in a collection. If any call returns true this returns
true (without checking the rest). If all returns false this returns false.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">col</span>
        : <span class="type">S</span>
        <div class="entryOverview">The collection-like object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <span class="type">function(this:T,?,?,S):boolean</span>
        <div class="entryOverview">The function to call for every
    value. This function takes 3 arguments (the value, the key or undefined
    if the collection has no notion of keys, and the collection) and should
    return a boolean.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <span class="type">T=</span>
        <div class="entryOverview">The object to be used as the value of 'this'
    within <code> f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            True if any value passes the test.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_structs_structs.js.source.html#line304">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>






      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory structs</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="" current="/goog/structs/structs.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
